﻿using System;
using System.Data;


public partial class manager_AllEval_Default : System.Web.UI.Page
{
    DBHelper db = new DBHelper();
    public int now_year;
    public int now_month;
    public int last_year;
    public int last_month;

    public string Html_Title = "";
    public string Html_Dept = "";
    public string Html_Dept_Detail = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        string dept = Session[AppConfig.SESSION_USER_DEPT].ToString();


        DateTime now = DateTime.Now;
        int day = now.Day;

        now_year = now.Year;
        now_month = now.Month;
        last_year = now.AddMonths(-1).Year;
        last_month = now.AddMonths(-1).Month;

        Button1.Text = now_year + "年" + now_month + "月考评";
        Button2.Text = last_year + "年" + last_month + "月考评";
        if (!IsPostBack)
        {
            GetDept();
            bindData();
        }
    }
    private void GetDept()
    {
        int i = 0;
        Html_Dept = "";
        DataTable dt = db.getList("select * from dict_dept where [isUsing]=1 order by id");
        foreach (DataRow dr in dt.Rows)
        {
            if (i == 0)
            {
                Html_Dept += "<li role=\"presentation\" class=\"active\"><a href=\"#dept_" + dr["id"].ToString() + "\" role=\"tab\" data-toggle=\"tab\">" + dr["mc"].ToString() + "</a></li>";
            }
            else
            {
                Html_Dept += "<li role=\"presentation\"><a href=\"#dept_" + dr["id"].ToString() + "\" role=\"tab\" data-toggle=\"tab\">" + dr["mc"].ToString() + "</a></li>";
            }
            i = 1;
        }


    }


    private void bindData()
    {
        Html_Title = now_year + "年" + now_month + "月考评";
        GetDept();
        GetData(now_year, now_month);
    }
    protected void btnUpdate_Click1(object sender, EventArgs e)
    {
        Html_Title = now_year + "年" + now_month + "月考评";
        GetDept();
        GetData(now_year, now_month);

    }
    protected void btnUpdate_Click2(object sender, EventArgs e)
    {
        Html_Title = last_year + "年" + last_month + "月考评";
        GetDept();
        GetData(last_year, last_month);
    }


    public void GetData(int year, int month)
    {
        dept_id.Value = "";
        int i = 0;
        DataTable dt = db.getList("select * from dict_dept where [isUsing]=1 order by id");
        foreach (DataRow dr in dt.Rows)
        {
            dept_id.Value = dept_id.Value + "|" + dr["id"].ToString();
            if (i == 0)
            { Html_Dept_Detail += "<div role=\"tabpanel\" class=\"tab-pane active\" id=\"dept_" + dr["id"].ToString() + "\">"; }
            else
            { Html_Dept_Detail += "<div role=\"tabpanel\" class=\"tab-pane\" id=\"dept_" + dr["id"].ToString() + "\">"; }

            Html_Dept_Detail += "<div class=\"box-body\">";
            Html_Dept_Detail += "<table id=\"table_" + dr["id"].ToString() + "\" class=\"table table-bordered table-striped\">";
            Html_Dept_Detail += "<thead>";
            Html_Dept_Detail += "<tr>";
            Html_Dept_Detail += "<th></th>";
            Html_Dept_Detail += "<th>岗位名称</th>";
            Html_Dept_Detail += "<th>考评日期</th>";
            Html_Dept_Detail += "<th>年度任务</th>";
            Html_Dept_Detail += "<th>月度任务</th>";
            Html_Dept_Detail += "<th>临时任务</th>";
            Html_Dept_Detail += "<th>特殊扣分</th>";
            Html_Dept_Detail += "<th>考评总分</th>";
            Html_Dept_Detail += "<th>查看</th>";
            Html_Dept_Detail += "</tr>";
            Html_Dept_Detail += "</thead>";
            Html_Dept_Detail += "<tbody>";
            string sql = "select * from v_A_Eval_Main where  [year]=" + year + " and [month]=" + month + "  and dept=" + dr["id"].ToString() + "  order by psid";
            DataTable dt1 = db.getList(sql);
            foreach (DataRow dr1 in dt1.Rows)
            {
                Html_Dept_Detail += "<asp:Repeater ID=\"rpt_hz\" runat=\"server\">";
                Html_Dept_Detail += "<ItemTemplate>";
                Html_Dept_Detail += "<tr>";
                Html_Dept_Detail += "<td>" + dr1["id"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["year"].ToString() + "年" + dr1["month"].ToString() + "月</td>";
                Html_Dept_Detail += "<td>【" + dr1["mc"].ToString() + "】" + dr1["userName"].ToString() + "</td>";

                Html_Dept_Detail += "<td>" + dr1["task_zx_s_0"].ToString() + "|" + dr1["task_zx_p_0"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["task_zx_s_1"].ToString() + "|" + dr1["task_zx_p_1"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["task_zx_s_2"].ToString() + "|" + dr1["task_zx_p_2"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["special"].ToString() + "</td>";
                Html_Dept_Detail += "<td>" + dr1["task_zx_p_zz"].ToString() + "</td>";

                Html_Dept_Detail += "<td>" + "<a target=\"_blank\" href=\"/manager/eval/View.aspx?id=" + dr1["ID"].ToString() + "&Year=" + dr1["year"].ToString() + "&Month=" + dr1["Month"].ToString() + "&psid=" + dr1["psid"].ToString() + "\">详细</a><a style=\"margin-left: 20px;\" href=\"/manager/eval/MyEval.aspx?&psid=" + dr1["psid"].ToString() + "\" target=\"_blank\">查看历史</a>" + "</td>";
                Html_Dept_Detail += "</tr>";
            }
            Html_Dept_Detail += "</tbody>";
            Html_Dept_Detail += "</table>";
            Html_Dept_Detail += "</div>";
            Html_Dept_Detail += "</div>";
            i = 1;
        }
    }





}